home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_05 / allison / tdate2.c < prev    next >
C/C++ Source or Header  |  1995-03-12  |  687b  |  32 lines

  1. LISTING 6 - Tests the new Date type
  2. /* tdate2.c */
  3. #include <stdio.h>
  4. #include "date2.h"
  5.  
  6. #define DATELEN 19
  7.  
  8. main()
  9. {
  10.     Date *d1 = date_create(10,1,1951),
  11.          *d2 = date_create(3,7,1995);
  12.     char buf[DATELEN+1];
  13.     int cmp;
  14.  
  15.     printf("d1 == %s\n",date_format(d1,buf));
  16.     printf("d2 == %s\n",date_format(d2,buf));
  17.     cmp = date_compare(d1,d2);
  18.     printf("d1 %s d2\n",(cmp < 0) ? "precedes"
  19.                                   : (cmp > 0) ? "follows"
  20.                                               : "equals");
  21.     date_destroy(d1);
  22.     date_destroy(d2);
  23.     return 0;
  24. }
  25.  
  26. /* Output:
  27. d1 == October 1, 1951
  28. d2 == March 7, 1995
  29. d1 precedes d2
  30. */
  31.  
  32.